//
//  ZHAlertView.m
//  Doctor
//
//  Created by liuzhishan on 15/12/23.
//  Copyright © 2015年 shanshan. All rights reserved.
//

#import "ZHAlertView.h"

@implementation ZHAlertView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addMyChildViews];
    }
    return self;
}

-(void)addMyChildViews
{
    
    UIImageView *imageView = [[UIImageView alloc]init];
    imageView.tag = 10012;
    imageView.image = [UIImage imageNamed:@"login-alert"];
    imageView.translatesAutoresizingMaskIntoConstraints = NO;

    [self addSubview:imageView];
 
    [self addConstraint:[NSLayoutConstraint constraintWithItem:imageView attribute:(NSLayoutAttributeLeft) relatedBy:(NSLayoutRelationEqual) toItem:self attribute:(NSLayoutAttributeLeft) multiplier:1.0 constant:0]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:imageView attribute:(NSLayoutAttributeRight) relatedBy:(NSLayoutRelationEqual) toItem:self attribute:(NSLayoutAttributeRight) multiplier:1.0 constant:0]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:imageView attribute:(NSLayoutAttributeTop) relatedBy:(NSLayoutRelationEqual) toItem:self attribute:(NSLayoutAttributeTop) multiplier:1.0 constant:0]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:imageView attribute:(NSLayoutAttributeBottom) relatedBy:(NSLayoutRelationEqual) toItem:self attribute:(NSLayoutAttributeBottom) multiplier:1.0 constant:0]];

    
    
    
    
    UILabel *lableShow = [[UILabel alloc]init];
    lableShow.tag = 10010;
    lableShow.textColor = BLUECOLOR;
    lableShow.textAlignment = NSTextAlignmentCenter;
    lableShow.translatesAutoresizingMaskIntoConstraints = NO;
    [self addSubview:lableShow];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:lableShow attribute:(NSLayoutAttributeLeft) relatedBy:(NSLayoutRelationEqual) toItem:self attribute:(NSLayoutAttributeLeft) multiplier:1.0 constant:5]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:lableShow attribute:(NSLayoutAttributeRight) relatedBy:(NSLayoutRelationEqual) toItem:self attribute:(NSLayoutAttributeRight) multiplier:1.0 constant:-5]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:lableShow attribute:(NSLayoutAttributeTop) relatedBy:(NSLayoutRelationEqual) toItem:self attribute:(NSLayoutAttributeTop) multiplier:1.0 constant:5]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:lableShow attribute:(NSLayoutAttributeBottom) relatedBy:(NSLayoutRelationEqual) toItem:self attribute:(NSLayoutAttributeBottom) multiplier:1.0 constant:-5]];

    
    
    
}

-(void)setAlertMessage:(NSString *)meg
{
    UILabel *lable  = (UILabel *)[self viewWithTag:10010];
    lable.text = meg;
}

-(void)setAlertMessage:(NSString *)meg andUIFond:(NSInteger)count andAlpha:(CGFloat)alphaCount
{
    UIImageView *imageView = (UIImageView *)[self viewWithTag:10012];
    imageView.image = nil;
    imageView.backgroundColor = [UIColor whiteColor];
    imageView.alpha = alphaCount;
    
    UILabel *lable  = (UILabel *)[self viewWithTag:10010];
    lable.font = [UIFont systemFontOfSize:count*WIDPro -2];
    lable.textColor = [UIColor grayColor];
    lable.text = meg;

}

-(void)setAlertMessage:(NSString *)meg andBgImageName:(NSString *)imageName
{
    UILabel *lable  = (UILabel *)[self viewWithTag:10010];
    lable.text = meg;
    
    UIImageView *imageView = (UIImageView *)[self viewWithTag:10012];
    imageView.image = [UIImage imageNamed:imageName];
}

@end
